<template>
  <el-card class="collapse-tab">
    <div class="content-slot">
      <slot />
    </div>
    <div class="toggle-button" @click="toggleTab">
      <i class="el-icon-caret-top" />
    </div>
  </el-card>
</template>

<script>
export default {
  methods: {
    toggleTab() {
      this.$('.collapse-tab').find('.content-slot').toggle(500)
      const icon = this.$('.collapse-tab').find('.toggle-button').find('i')
      icon.attr('class') === 'el-icon-caret-top' ? icon.attr('class', 'el-icon-caret-bottom') : icon.attr('class', 'el-icon-caret-top')
    }
  }
}
</script>

<style lang="scss">
.collapse-tab > .el-card__body{
  padding: 0px;
}
</style>

<style lang="scss" scoped>
.collapse-tab {
  .content-slot {
    padding: 20px 20px 0px 20px
  }
  .toggle-button{
    text-align:center;
    height:24px;
    line-height: 24px;
    color: #d3dce6;
    font-size: 24px;
    cursor: pointer;
    &:hover{
      background-color: #f9fafc;
      color: #1890FF;
    }
  }
}
</style>
